package org.csmzxy.class2333.innerclass;

public class Example19 {
    public static void learnSwim(Swim swim) {
        swim.swimming();
    }

    public static void main(String[] args) {
        String name = "小明";
        //调用learnSwim()方法，将匿名内部类对象作为参数传入
        learnSwim(new Swim() {
            @Override
            public void swimming() {
                System.out.println(name + "学会了自由泳……");
            }
        });
        //调用learnSwim()方法，将匿名内部类对象作为参数传入
        learnSwim(new Swim() {
            @Override
            public void swimming() {
                System.out.println(name + "学会了蛙泳……");
            }
        });
    }
}